home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / usr / share / system-config-printer / troubleshoot / Shrug.py < prev    next >
Encoding:
Python Source  |  2010-09-28  |  3.3 KB  |  85 lines

  1. #!/usr/bin/env python
  2.  
  3. ## Printing troubleshooter
  4.  
  5. ## Copyright (C) 2008, 2009, 2010 Red Hat, Inc.
  6. ## Author: Tim Waugh <twaugh@redhat.com>
  7.  
  8. ## This program is free software; you can redistribute it and/or modify
  9. ## it under the terms of the GNU General Public License as published by
  10. ## the Free Software Foundation; either version 2 of the License, or
  11. ## (at your option) any later version.
  12.  
  13. ## This program is distributed in the hope that it will be useful,
  14. ## but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16. ## GNU General Public License for more details.
  17.  
  18. ## You should have received a copy of the GNU General Public License
  19. ## along with this program; if not, write to the Free Software
  20. ## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  21.  
  22. from base import *
  23. class Shrug(Question):
  24.     def __init__ (self, troubleshooter):
  25.         Question.__init__ (self, troubleshooter, "Shrug")
  26.         page = self.initial_vbox (_("Sorry!"),
  27.                                   _("There is no obvious solution to this "
  28.                                     "problem.  Your answers have been "
  29.                                     "collected together with "
  30.                                     "other useful information.  If you "
  31.                                     "would like to report a bug, please "
  32.                                     "include this information."))
  33.  
  34.         expander = gtk.Expander (_("Diagnostic Output (Advanced)"))
  35.         expander.set_expanded (False)
  36.         sw = gtk.ScrolledWindow ()
  37.         expander.add (sw)
  38.         textview = gtk.TextView ()
  39.         textview.set_editable (False)
  40.         sw.add (textview)
  41.         page.pack_start (expander)
  42.         self.buffer = textview.get_buffer ()
  43.  
  44.         box = gtk.HButtonBox ()
  45.         box.set_border_width (0)
  46.         box.set_spacing (3)
  47.         box.set_layout (gtk.BUTTONBOX_END)
  48.         page.pack_start (box, False, False, 0)
  49.  
  50.         self.save = gtk.Button (stock=gtk.STOCK_SAVE)
  51.         box.pack_start (self.save, False, False, 0)
  52.  
  53.         troubleshooter.new_page (page, self)
  54.  
  55.     def display (self):
  56.         self.buffer.set_text (self.troubleshooter.answers_as_text ())
  57.         return True
  58.  
  59.     def connect_signals (self, handler):
  60.         self.save_sigid = self.save.connect ('clicked', self.on_save_clicked)
  61.  
  62.     def disconnect_signals (self):
  63.         self.save.disconnect (self.save_sigid)
  64.  
  65.     def on_save_clicked (self, button):
  66.         dialog = gtk.FileChooserDialog (parent=self.troubleshooter.get_window(),
  67.                                         action=gtk.FILE_CHOOSER_ACTION_SAVE,
  68.                                         buttons=(gtk.STOCK_CANCEL,
  69.                                                  gtk.RESPONSE_CANCEL,
  70.                                                  gtk.STOCK_SAVE,
  71.                                                  gtk.RESPONSE_OK))
  72.         dialog.set_do_overwrite_confirmation (True)
  73.         dialog.set_current_name ("troubleshoot.txt")
  74.         dialog.set_default_response (gtk.RESPONSE_OK)
  75.         dialog.set_local_only (True)
  76.         response = dialog.run ()
  77.         dialog.hide ()
  78.         if response != gtk.RESPONSE_OK:
  79.             return
  80.  
  81.         f = file (dialog.get_filename (), "w")
  82.         f.write (self.buffer.get_text (self.buffer.get_start_iter (),
  83.                                        self.buffer.get_end_iter ()))
  84.         del f
  85.